package com.dhy.takeaway.controller;

import com.dhy.takeaway.entity.Address;
import com.dhy.takeaway.entity.Res;
import com.dhy.takeaway.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class AddressController {

    @Autowired
    AddressService addressService;

    @PostMapping("/findAddress")
    public List<Address> findAddress(@RequestBody Address address){
        return addressService.findAddress(address.getBuyerId());
    }

    @PostMapping("/editAddress")
    public Res editAddress(@RequestBody Address address){
        return addressService.editAddress(address);
    }

    @PostMapping("/delAddress")
    public Res delAddress(@RequestBody Address address){
        return addressService.deleteAddress(address.getId());
    }

}
